<?php
/**
 * User: aka
 * Time: 12:53
 */

namespace app\secret\controller;


class ChatRoom
{
    public function index()
    {
        $chatLastId = \app\secret\model\ChatRoom::order('id desc')
            ->limit(1)->find();
        $chatList = \app\secret\model\ChatRoom::order('id desc')
            ->limit(2)->select()->each(
                function($item)
                {
                    $item->user_id = \app\secret\model\Users::userInfo($item->user_id)
                        ->find();
                    $item->ip = get_ip_city($item->ip);
                }
            );
        return view('index', ['chat_list' => $chatList, 'chat_last_id' => $chatLastId['id']+1]);
    }
}